﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using DevComponents.DotNetBar.Keyboard;
using DevExpress.XtraEditors;

namespace Submitter
{
    public partial class NumberKeyboardUserControl : DevExpress.XtraEditors.XtraUserControl
    {
        public NumberKeyboardUserControl()
        {
            InitializeComponent();

            this.VisibleChanged += (sender, args) => this.textEdit1.SelectAll();

            //keyboardControl1.Keyboard = CreateLayout();
            //keyboardControl1.Invalidate();
        }

        public object EditValue
        {
            get { return textEdit1.EditValue; }
            set { textEdit1.EditValue = value; }
        }


        private Keyboard CreateLayout()
        {
            var keyboard = new Keyboard();

            var klNumLockOn = new LinearKeyboardLayout();

            klNumLockOn.AddKey("7", style: KeyStyle.Light);
            klNumLockOn.AddKey("8", style: KeyStyle.Light);
            klNumLockOn.AddKey("9", style: KeyStyle.Light);
            klNumLockOn.AddLine();

            klNumLockOn.AddKey("4", style: KeyStyle.Light);
            klNumLockOn.AddKey("5", style: KeyStyle.Light);
            klNumLockOn.AddKey("6", style: KeyStyle.Light);
            klNumLockOn.AddLine();

            klNumLockOn.AddKey("1", style: KeyStyle.Light);
            klNumLockOn.AddKey("2", style: KeyStyle.Light);
            klNumLockOn.AddKey("3", style: KeyStyle.Light);
            klNumLockOn.AddLine();

            klNumLockOn.AddKey("0", style: KeyStyle.Light);
            klNumLockOn.AddKey("Del", "{Delete}");
            klNumLockOn.AddKey("回退", "{BACKSPACE}");


            keyboard.Layouts.Add(klNumLockOn);
            return keyboard;

        }
    }
}
